home *** CD-ROM | disk | FTP | other *** search
/ Mac-Source 1994 July / Mac-Source_July_1994.iso / C and C++ / Graphics⁄Sound / crit / critic.c next >
Encoding:
C/C++ Source or Header  |  1987-05-24  |  2.4 KB  |  123 lines  |  [TEXT/????]

  1. /*
  2.  * critic.c - initialization (and data definition) for the talking bore.
  3.  * This program was created with Aztec C Developers' version 1.06I
  4.  */
  5.  
  6. #include <quickdraw.h>
  7. #include <font.h>
  8. #include <window.h>
  9. #include <osutil.h>
  10. #include <menu.h>
  11. #include <event.h>
  12. #include <textedit.h>
  13. #include <dialog.h>
  14. #include <desk.h>
  15. #include <control.h>
  16. #include <toolutil.h>
  17. #include <resource.h>
  18. #include <packages.h>
  19.  
  20. #define DATA
  21. #include "critic.h"
  22. #undef DATA
  23.  
  24. #define maxStackSize 8192    /* max size of stack; the heap gets the rest */
  25.  
  26. /*
  27.  * main() - start the program.
  28.  */
  29.  
  30. main()
  31. {
  32.     /*
  33.      * Initialize the Toolbox managers (order is important).
  34.      */
  35.  
  36.     mem_init();
  37.     InitGraf(&thePort);
  38.     InitFonts();
  39.     InitWindows();
  40.     InitMenus();
  41.     TEInit();
  42.     InitDialogs((ProcPtr) 0);
  43.     InitCursor();
  44.     DILoad();
  45.     SetEventMask(everyEvent - keyUpMask);
  46.     GetWMgrPort(&screenport);
  47.     SetPort(screenport);
  48.  
  49.     menu_init();
  50.     wind_init();
  51.     doc_init();
  52.     voice_init();
  53.  
  54.     /*
  55.      * Set the port to the program's window,
  56.      * then handle events until a "Quit" event is detected.
  57.      */
  58.  
  59.     SetPort(windoc);
  60.     while (doevent())
  61.     ;
  62.     closeup();
  63. }
  64.  
  65. /*
  66.  * closeup() - prepare to exit the program.
  67.  */
  68.  
  69. closeup()
  70. {
  71.     voice_stop();
  72.     SetEventMask(everyEvent - keyUpMask); /* restore default event mask */
  73.     DIUnload();
  74.     InitCursor();
  75. }
  76.  
  77. /*
  78.  * mem_init() - initialize the memory.
  79.  */
  80.  
  81. mem_init()
  82. {
  83.     long *stackbaseptr;        /* points to current stack base      */
  84.  
  85.     /*
  86.      * Allocate everything but the Max Stack Size to the Heap.
  87.      */
  88.  
  89.     stackbaseptr = (long *) 0x908; /* CurStackBase from Tlasm/sysequ.text */
  90.     SetApplLimit((Ptr) (*stackbaseptr - maxStackSize));
  91.  
  92.     /*
  93.      * Expand the application heap zone to its maximum size, without
  94.      * purging any purgeable resources.  This saves memory compactions
  95.      * and heap expansions later.
  96.      */
  97.  
  98.     MaxApplZone();
  99.  
  100.     /* 
  101.      * get plenty of master pointers now; if we let the Memory Manager
  102.      * allocate them as needed, they'd form non-relocatable islands in
  103.      * the heap.
  104.      *
  105.      * Inside Mac says each call to MoreMasters() currently allocates 64 masters.
  106.      * That's not a whole lot.
  107.      */
  108.  
  109.     MoreMasters();
  110.     MoreMasters();
  111. }
  112.  
  113. /*
  114.  * wind_init() - create the document window.
  115.  */
  116.  
  117. wind_init()
  118. {
  119.     static WindowRecord wrecord;    /* storage for our window    */
  120.  
  121.     windoc = GetNewWindow(WINDOWID, &wrecord, (long) -1);
  122. }
  123.